<%@ page import="java.net.URL, java.io.*, java.util.regex.Matcher, java.util.regex.Pattern" %>

<%

	String url=request.getParameter("url");

	final String CAT_PATTERN = 
//		"<div class=\"forum_name\"><a href=\"[^\"]*\" title=\"[^\"]*\" >([^<]*)</a></div>\\s*<div>([^<]*)</div>\\s*<div>Discussions:\\s*([^\\s]*)\\s*Messages:\\s*([^\\s]*)";
		"/forums/[^>]*>([^<]*)</a>.*?<p>([^<]*)</p>.*?\">\\s*([^\\s]*).*?\">\\s*([^\\s]*)";

	Pattern catPattern;
	Matcher result;

	catPattern = Pattern.compile(CAT_PATTERN);


    
        URL newURL = new URL(url);
        BufferedReader webpage = new BufferedReader(new InputStreamReader(newURL.openStream()));

        String inputLine;
	String output="";
                
        while ((inputLine = webpage.readLine()) != null)
                                
            output+=inputLine;

//	String output="<div class=\"forum_name\"><a href=\"/forums/2/Anime-Series/Anime-Series\" title=\"Anime-Series\" >Anime Series</a></div>";



	result = catPattern.matcher(output);
	out.println("<br/>");
%>
<table border="1">
<tr><th>Cat Name<th>Description<th>Topics<th>Posts
<%

	while(result.find())
		out.println("<tr><td>"+result.group(1)+"<td>"+result.group(2)+"<td>"+result.group(3)+"<td>"+result.group(4)+"</tr>");
                        

%>
</table>

